#include "appwindow.hpp"

AppWindow::AppWindow()
{
  set_title("CS488 Assignment Two");

  // A utility class for constructing things that go into menus, which
  // we'll set up next.
  using Gtk::Menu_Helpers::MenuElem;
  using Gtk::Menu_Helpers::RadioMenuElem;  
  // Set up the application menu
  // The slot we use here just causes AppWindow::hide() on this,
  // which shuts down the application.
	m_menu_app.items().push_back(MenuElem("_Reset", Gtk::AccelKey("a"),
	    sigc::mem_fun(m_viewer, &Viewer::reset_view)));
  m_menu_app.items().push_back(MenuElem("_Quit", Gtk::AccelKey("q"),
    sigc::mem_fun(*this, &AppWindow::hide)));
  
	// mode slot
    sigc::slot1<void, Viewer::myMode> mode_slot = 
  	sigc::mem_fun(m_viewer, &Viewer::set_mode);
    // mode menu
    Gtk::RadioMenuItem::Group radio_group_mode;
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "Model Rotate", Gtk::AccelKey("r"), 
        sigc::bind(mode_slot, Viewer::MODELROTATE)));
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "Model Translate", Gtk::AccelKey("t"), 
        sigc::bind(mode_slot, Viewer::MODELTRANSLATE)));
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "Model Scale", Gtk::AccelKey("s"), 
        sigc::bind(mode_slot, Viewer::MODELSCALE)));
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "View Rotate", Gtk::AccelKey("o"), 
        sigc::bind(mode_slot, Viewer::VIEWROTATE)));
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "View Translate", Gtk::AccelKey("n"), 
        sigc::bind(mode_slot, Viewer::VIEWTRANSLATE)));
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "Perspective", Gtk::AccelKey("p"), 
        sigc::bind(mode_slot, Viewer::VIEWPERSPECTIVE)));
	m_menu_mode.items().push_back( RadioMenuElem(
        radio_group_mode, "Viewport", Gtk::AccelKey("v"), 
        sigc::bind(mode_slot, Viewer::VIEWPORT)));

  // Set up the menu bar
  m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Application", m_menu_app));
	m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Mode", m_menu_mode));
  
  // Pack in our widgets
  
  // First add the vertical box as our single "top" widget
  add(m_vbox);

  // Put the menubar on the top, and make it as small as possible
  m_vbox.pack_start(m_menubar, Gtk::PACK_SHRINK);

  // Put the viewer below the menubar. pack_start "grows" the widget
  // by default, so it'll take up the rest of the window.
  m_viewer.set_size_request(300, 300);
  m_vbox.pack_start(m_viewer);

	m_label.set_size_request(300,50);
	m_viewer.set_label(&m_label);
	m_vbox.pack_start(m_label);

	m_viewer.set_mode_menu(&m_menu_mode);
	
  show_all();
}
